package com.jsoft.jsofted.framework.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.diboot.core.binding.annotation.BindField;
import com.gitee.sunchenbin.mybatis.actable.annotation.Column;
import com.jsoft.jsofted.sys.entity.OrgEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.util.StringUtils;

/**
 * 有机构归属的实体类：即数据归属于某个特定的机构。
 */
@Data
@EqualsAndHashCode(callSuper = false)
public abstract class OfOrgEntity extends OfTenantEntity {

    @Column
    protected Long orgId;

    @TableField(exist = false)
    @BindField(entity = OrgEntity.class, field = "name", condition = "org_id=id")
    protected String orgName;

    @TableField(exist = false)
    @BindField(entity = OrgEntity.class, field = "fullName", condition = "org_id=id")
    protected String orgFullName;

    public String getOrgFullName() {
        if (StringUtils.hasText(orgFullName)) {
            return this.orgFullName;
        }
        return this.orgName;
    }
}
